cmake_minimum_required(VERSION 3.5)
option(ENABLE_TESTING "Enable testing" OFF)
option(CODE_COVERAGE "Enable coverage reporting" OFF)
add_library(set_stl set_stl.cpp)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    target_compile_options(set_stl PRIVATE --coverage)
    target_link_options(set_stl INTERFACE --coverage)
endif()
if(UNIX)
    SET_TARGET_PROPERTIES(set_stl PROPERTIES COMPILE_FLAGS "-fPIC")
endif()
if(ENABLE_TESTING AND (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
  find_package(GTest REQUIRED)
  include_directories(${GTEST_INCLUDE_DIR})
  add_executable(test_set test.cpp)
  target_link_libraries(test_set set_stl)
    if(WIN32)
    target_link_libraries(test_set debug ${GTEST_MAIN_LIBRARY_DEBUG} debug ${GTEST_LIBRARY_DEBUG})
    target_link_libraries(test_set optimized ${GTEST_MAIN_LIBRARY} optimized ${GTEST_LIBRARY})
    elseif(UNIX)
    target_link_libraries(test_set ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} pthread)
    endif()  
endif()
